package com.game.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.game.pojo.po.ChatRecord;
import com.game.dao.ChatRecordDao;
import com.game.service.ChatRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lvhao
 * @since 2020-09-17
 */
@Service
public class ChatRecordServiceImpl extends ServiceImpl<ChatRecordDao, ChatRecord> implements ChatRecordService {
    @Resource
    private ChatRecordDao chatRecordDao;

    @Override
    public List<ChatRecord> getByNumAndTime(int num) {
        IPage<ChatRecord> page = new Page<>(1, num);
        QueryWrapper<ChatRecord> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("time");
        page = chatRecordDao.selectPage(page, queryWrapper);
        return page.getRecords();
    }
}
